#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

vector<string> gen_grid(int N, int black_ratio=50) {
    vector<string> grid(N);
    for (int i = 0; i < N; i++) {
        string row = "";
        for (int j = 0; j < N; j++) {
            if (rnd.next(1, 100) <= black_ratio) {
                row += "#";
            } else {
                row += ".";
            }
        }
        grid[i] = row;
    }
    return grid;
}

// 生成测试用例
void test(int index, ostream& cout) {
    int N, M;
    
    switch(index) {
        case 1: // 样例1
            cout << "3 2" << endl;
            cout << "..." << endl;
            cout << "###" << endl;
            cout << "#.#" << endl;
            return;
        case 2: // 样例2
            cout << "10 3" << endl;
            cout << "..#......." << endl;
            cout << ".###......" << endl;
            cout << ".#.#......" << endl;
            cout << "#####....." << endl;
            cout << "#...#....." << endl;
            cout << "......####" << endl;
            cout << "......#..#" << endl;
            cout << "......#..." << endl;
            cout << "......#..#" << endl;
            cout << "......####" << endl;
            return;
        case 3: // 边界情况：最小规模
            N = 1; M = 1;
            break;
        case 4: // 边界情况：最大规模
            N = 10; M = 10;
            break;
        case 5: // 边界情况：M=1
            N = 10; M = 1;
            break;
        case 6: // 边界情况：M=N
            N = 5; M = 5;
            break;
        case 7: case 8: case 9: case 10: // 中等规模
            N = rnd.next(3, 8);
            M = rnd.next(1, N);
            break;
        default: // 一般情况
            N = rnd.next(1, 10);
            M = rnd.next(1, N);
            break;
    }
    
    cout << N << " " << M << endl;
    vector<string> grid = gen_grid(N, 50);
    for (int i = 0; i < N; i++) {
        cout << grid[i] << endl;
    }
}